package api

import (
	"log"

	"github.com/gin-gonic/gin"
)

func GetBffServer(confPath string, callback func(engine *gin.Engine)) *gin.Engine {
	if confPath == "" {
		log.Fatal("confPath is invalid")
		return nil
	}
	if callback == nil {
		log.Fatal("callback is nil")
		return nil
	}
	conf, error := ParseAppGlobal(confPath)
	if error != nil {
		log.Fatal("ParseBffConfig is error")
		return nil
	}
	engine := gin.Default()
	callback(engine)
	engine.Run(":" + conf.Port)
	return engine
}
